/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.worlds.ui;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.MutableTreeNode;
import net.worlds.WorldsException;
import net.worlds.Main;
import net.worlds.object.GameObject;
import net.worlds.object.World;


public class PartTreeNode extends DefaultMutableTreeNode {
    private GameObject obj;
    public PartTreeNode(GameObject obj)
    {
        setUserObject(this);
        this.obj = obj;
    }
    public GameObject getObject()
    {
        return obj;
    }
    @Override
    public void add(MutableTreeNode c)
    {
        super.add(c);
        if(!Main.noView)
            Main.getApplet().getPartsTree().getModel().nodesWereInserted(this, new int[]{getIndex(c)});
    }
    public void remove()
    {

    }
    @Override
    public String toString()
    {
        try {
            return obj.getStringProp("Name");
        } catch (WorldsException ex) {
            return "";
        }
    }
}
